package com.example.play.config.mvc;

import com.example.play.bean.Config;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import java.nio.file.Paths;

/**
 * @author wsl
 * @version 1.0
 * @date 2020/5/18
 * @description 这是返回值配置
 */

@Configuration
public class WebAppConfigurer implements WebMvcConfigurer {

    @Autowired
    private Config config;


    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler ("/" + config.getFileUrl () + "/**")
                .addResourceLocations ("file:" + Paths.get (config.getFilePath ()) + "/");

    }


}

